package nowcoder.ali;

import java.util.*;

public class Cmn {

    //主要思想就是回溯
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), m = sc.nextInt();
        ArrayList<Integer> record = new ArrayList<>();
        for (int i = 1; i <= n; i++) {
            backTrace(record,i,m,n);
        }
    }

    public static void backTrace(ArrayList<Integer> record, int i, int m, int n){
        if(i>n||record.size()>=m) return;
        record.add(i);
        if(record.size()==m){
            for (Integer integer : record) {
                System.out.print(integer);
                System.out.print(" ");
            }
            System.out.println();
        }
        for (int j = i+1; j <= n ; j++) {
            backTrace(record,j,m,n);
        }
        record.remove(record.size()-1);
    }
}
